/*
* baseaicode13
*/
package com.kun.sun.baseaicode133.ctrl;

import com.alibaba.fastjson.JSON;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import javax.annotation.Resource;
import java.util.List;
import java.util.HashMap;

import com.kun.sun.core.entity.BeanRet;
import com.kun.sun.core.entity.Page;
import com.kun.sun.core.tools.redis.RedisUtils;
import com.kun.sun.baseaicode133.entity.Baseaicode133;
import com.kun.sun.baseaicode133.service.Baseaicode133SV;

/**
*  控制器
*
* @author baseaicode13
*/
@RestController
@RequestMapping("/baseaicode133")
@Slf4j
@Api(value = "控制器", description = "控制器")
public class Baseaicode133Ctrl {

    @Resource
    protected RedisUtils redisUtils;

    @Resource
    private Baseaicode133SV baseaicode133SV;

    /**
    * 查询Baseaicode133一个详情信息
    * @param id 
    * @param code 
    * @return BeanRet
    */
    @ApiOperation(value = "查询Baseaicode133一个详情信息", notes = "查询Baseaicode133一个详情信息")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "id", value = "",dataType = "java.lang.Long", paramType = "query"),
        @ApiImplicitParam(name = "code", value = "",dataType = "java.lang.Object", paramType = "query")
    })
    @GetMapping(value = "/load")
    @ResponseBody
    public Baseaicode133 load(java.lang.Long id,java.lang.Object code) {
        if(id==null){
        return null;
        }
        if(code==null){
        return null;
        }
        Baseaicode133 baseaicode133 = baseaicode133SV.load(id,code);
        log.info(JSON.toJSONString(baseaicode133));
        return baseaicode133;
    }


    /**
    * 根据条件id查询Baseaicode133一个详情信息
    *
    * @param id 
    * @return BeanRet
    */
    @ApiOperation(value = "查询Baseaicode133一个详情信息", notes = "查询Baseaicode133一个详情信息")
    @ApiImplicitParams({
       @ApiImplicitParam(name = "id", value = "",dataType = "java.lang.Long", paramType = "path")
    })
    @GetMapping(value = "/load/id/{id}")
    @ResponseBody
    public Baseaicode133 loadById(@PathVariable java.lang.Long id) {
        if(id==null){
           return null;
        }
        Baseaicode133 baseaicode133 = baseaicode133SV.loadById(id);
        log.info(JSON.toJSONString(baseaicode133));
        return baseaicode133;
    }
    /**
    * 根据条件code查询Baseaicode133一个详情信息
    *
    * @param code 
    * @return BeanRet
    */
    @ApiOperation(value = "查询Baseaicode133一个详情信息", notes = "查询Baseaicode133一个详情信息")
    @ApiImplicitParams({
       @ApiImplicitParam(name = "code", value = "",dataType = "java.lang.Object", paramType = "path")
    })
    @GetMapping(value = "/load/code/{code}")
    @ResponseBody
    public Baseaicode133 loadByCode(@PathVariable java.lang.Object code) {
        if(code==null){
           return null;
        }
        Baseaicode133 baseaicode133 = baseaicode133SV.loadByCode(code);
        log.info(JSON.toJSONString(baseaicode133));
        return baseaicode133;
    }


    /**
    * 查询Baseaicode133信息集合
    *
    * @return 分页对象
    */
    @ApiOperation(value = "查询Baseaicode133信息集合", notes = "查询Baseaicode133信息集合")
    @ApiImplicitParams({
    @ApiImplicitParam(name = "curPage", value = "当前页", required = true, paramType = "query"),
    @ApiImplicitParam(name = "pageSize", value = "分页大小", required = true, paramType = "query"),
    })
    @PostMapping(value = "/list")
    @ResponseBody
    public List<Baseaicode133> list(@RequestBody @ApiIgnore Baseaicode133 baseaicode133,Integer curPage,Integer pageSize) {
        Page<Baseaicode133> page=new Page<Baseaicode133>(pageSize,curPage);
        List<Baseaicode133> baseaicode133s = baseaicode133SV.list(baseaicode133,page.genRowStart(),page.getPageSize());
        int total = baseaicode133SV.count(baseaicode133);
        page.setTotalRow(total);
        log.info(JSON.toJSONString(page));
        return baseaicode133s;
    }


    /**
    * 查询Baseaicode133信息集合
    *
    * @return 分页对象
    */
    @ApiOperation(value = "查询Baseaicode133信息集合", notes = "查询Baseaicode133信息集合")
    @ApiImplicitParams({
    @ApiImplicitParam(name = "curPage", value = "当前页", required = true, paramType = "query"),
    @ApiImplicitParam(name = "pageSize", value = "分页大小", required = true, paramType = "query"),
    @ApiImplicitParam(name = "id", value = "", paramType = "query"),
    @ApiImplicitParam(name = "code", value = "", paramType = "query")
    })
    @GetMapping(value = "/list/by")
    @ResponseBody
    public List<Baseaicode133> listByPk(java.lang.Long id,java.lang.Object code,Integer curPage,Integer pageSize) {
        Page<Baseaicode133> page=new Page<Baseaicode133>(pageSize,curPage);
        List<Baseaicode133> baseaicode133s = baseaicode133SV.list(id,code, page.genRowStart(),page.getPageSize());
        int total = baseaicode133SV.count(id,code);
        page.setTotalRow(total);
        log.info(JSON.toJSONString(page));
        return baseaicode133s;
    }

    /**
    * 统计Baseaicode133信息数量根据主键
    *
    * @return 总条数
    */
    @ApiOperation(value = " 统计Baseaicode133信息数量根据主键", notes = " 统计Baseaicode133信息数量根据主键")
    @ApiImplicitParams({
    @ApiImplicitParam(name = "id", value = "", paramType = "query"),
    @ApiImplicitParam(name = "code", value = "", paramType = "query")
    })
    @GetMapping(value = "/count/by")
    @ResponseBody
    public Integer count(java.lang.Long id,java.lang.Object code) {
        return baseaicode133SV.count(id,code);
    }

    /**
    * 统计Baseaicode133信息数量
    *
    * @return 总条数
    */
    @ApiOperation(value = "统计Baseaicode133信息数量", notes = "统计Baseaicode133信息数量")
    @ApiImplicitParams({
    @ApiImplicitParam(name = "id", value = "", paramType = "query"),
    @ApiImplicitParam(name = "code", value = "", paramType = "query"),
    @ApiImplicitParam(name = "account", value = "", paramType = "query"),
    @ApiImplicitParam(name = "password", value = "", paramType = "query")
    })
    @PostMapping(value = "/count")
    @ResponseBody
    public Integer count(@RequestBody Baseaicode133 baseaicode133) {
        if(baseaicode133==null){
            return baseaicode133SV.count(new HashMap());
        }else{
            return baseaicode133SV.count(baseaicode133);
        }
    }



    /**
    * 创建Baseaicode133
    *
    * @return BeanRet
    */
    @ApiOperation(value = "创建Baseaicode133", notes = "创建Baseaicode133")
    @ApiImplicitParams({
    @ApiImplicitParam(name = "account", value = "", paramType = "query"),
    @ApiImplicitParam(name = "password", value = "", paramType = "query")
    })
    @PostMapping("/build")
    @ResponseBody
    public Baseaicode133 build(@RequestBody @ApiIgnore Baseaicode133 baseaicode133) {
        baseaicode133SV.save(baseaicode133);
        return baseaicode133;
    }


    /**
    * 修改Baseaicode133
    *
    * @return BeanRet
    */
    @ApiOperation(value = "修改Baseaicode133", notes = "修改Baseaicode133")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "id", value = "", paramType = "query"),
        @ApiImplicitParam(name = "code", value = "", paramType = "query"),
        @ApiImplicitParam(name = "account", value = "", paramType = "query"),
        @ApiImplicitParam(name = "password", value = "", paramType = "query")
    })
    @PutMapping("/modify")
    @ResponseBody
    public Baseaicode133 modify(@ApiIgnore Baseaicode133 baseaicode133) {
        baseaicode133SV.modify(baseaicode133);
        return baseaicode133;
    }

    /**
    * 删除Baseaicode133
    *
    * @return BeanRet
    */
    @ApiOperation(value = "删除Baseaicode133", notes = "删除Baseaicode133")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "id", value = "", paramType = "query"),
        @ApiImplicitParam(name = "code", value = "", paramType = "query")
    })
    @DeleteMapping("/delete")
    @ResponseBody
    public BeanRet delete(java.lang.Long id,java.lang.Object code) {
        baseaicode133SV.delete(id,code);
        return BeanRet.create(true, "删除Baseaicode133成功");
    }

}
